﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model.So;
using nERP.Model.Bas;
using nERP.Model.Wms;

namespace nERP.Model.Wms
{
    /// <summary>
    /// 销售退货入库
    /// </summary>
	[Table("SaleReturnInWarehouse")]
    [SoftKey(nameof(SaleReturnInWarehouse.SaleReturnInWarehouseCode))]
    [Display(Name = "_Model.SaleReturnInWarehouse")]
    public class SaleReturnInWarehouse : BasePoco,IPersistPoco,ITenant,IWorkflow
    {
        [Display(Name = "_Model._SaleReturnInWarehouse._SaleReturnInWarehouseCode")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("入库单号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [CanNotEdit]
        public string SaleReturnInWarehouseCode { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._SaleReturn")]
        [Comment("销售退货")]
        [NotMapped]
        public SaleReturn SaleReturn { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._SaleReturn")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("销售退货")]
        public string SaleReturnId { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._Sale")]
        [Comment("销售订单")]
        [NotMapped]
        public Sale Sale { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._Sale")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("销售订单")]
        public string SaleId { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._Customer")]
        [Comment("客户")]
        [NotMapped]
        public Customer Customer { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._Customer")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("客户")]
        public string CustomerId { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._InvoicesDate")]
        [Comment("单据日期")]
        public DateTime? InvoicesDate { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._InvoicesFile")]
        [Comment("单据附件")]
        public List<SaleReturnInWarehouseInvoicesFile> InvoicesFile { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._MakeUser")]
        [Comment("制单人")]
        [NotMapped]
        public FrameworkUser MakeUser { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._MakeUser")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("制单人")]
        public string MakeUserId { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._Status")]
        [Comment("单据状态")]
        public StatusTypeEnum? Status { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._Remark")]
        [StringLength(256, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("备注")]
        public string Remark { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouseDetail._SaleReturnInWarehouse")]
        [InverseProperty("SaleReturnInWarehouse")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.SaleReturnInWarehouseDetail.SaleReturnInWarehouseId))]
        public List<SaleReturnInWarehouseDetail> SaleReturnInWarehouseDetail_SaleReturnInWarehouse { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouse._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}
    public class SaleReturnInWarehouseInvoicesFile : TopBasePoco, ISubFile
    {
        public Guid SaleReturnInWarehouseId { get; set; }
        public SaleReturnInWarehouse SaleReturnInWarehouse { get; set; }
        public Guid FileId { get; set; }
        public FileAttachment File { get; set; }
        public int Order { get; set; }
    }

}
